-
Notifications
You must be signed in to change notification settings - Fork 35
[CTL] Add support for defaults #1216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2ec6659
to
408f2c4
Compare
umf_os_memory_provider_params_handle_t os_memory_provider_params = NULL; | ||
umf_memory_provider_ops_t *os_provider_ops = umfOsMemoryProviderOps(); | ||
if (os_provider_ops == NULL) { | ||
GTEST_SKIP() << "OS memory provider is not supported!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding such skip msg, I guess we should add this test in CMake only when OS prov and disjoint pool are enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's what for we've added a dummy function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yy? not sure what you mean
@@ -35,7 +35,7 @@ TEST_F(test, ctl_by_handle_os_provider) { | |||
|
|||
int ipc_enabled = 0xBAD; | |||
ret = umfCtlGet("umf.provider.by_handle.params.ipc_enabled", hProvider, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have any test for umfCtlGet
that pass something else than 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see it's not a part of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're adding a new paramter and without testing values other than 0 it's not properly tested. At least mark in tests a TODO for future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This callback discard completely size, so such test will cover completely nothing and will test nothing.
static int CTL_READ_HANDLER(ipc_enabled)(void *ctx,
umf_ctl_query_source_t source,
void *arg, size_t size,
umf_ctl_index_utlist_t *indexes,
const char *extra_name,
umf_ctl_query_type_t query_type) {
/* suppress unused-parameter errors */
(void)source, (void)indexes, (void)ctx, (void)extra_name, (void)query_type,
(void)size;
int *arg_out = arg;
os_memory_provider_t *os_provider = (os_memory_provider_t *)ctx;
*arg_out = os_provider->IPC_enabled;
return 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reading your last comment as "size is useless" ;)
Let me re-phrase - whenever size is used, please add a test with various values (user may give some input we may not expect, e.g. on wrong assumptions on how this func works) or mark a TODO for adding tests in the future.
b7324ed
to
8e3a2fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
umf_result_t umfCtlExec(const char *name, void *ctx, void *arg); should also have arg size imho.
src/ctl/ctl.c
Outdated
@@ -416,11 +402,14 @@ int ctl_query(struct ctl *ctl, void *ctx, umf_ctl_query_source_t source, | |||
errno = EINVAL; | |||
goto out; | |||
} | |||
const char *extra_name = &name[0]; | |||
if (strstr(extra_name, "by_handle") != NULL) { | |||
extra_name = &name[0] + name_offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not include UMF specyfic soultions in ctl* files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/memory_pool.c
Outdated
const char *extra_name, | ||
umf_ctl_query_type_t queryType) { | ||
(void)indexes, (void)source, (void)size, (void)ctx; | ||
assert(queryType == CTL_QUERY_WRITE && "not supported query type"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an assert. This sould return a correct error code to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- read should work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
src/memory_pool.c
Outdated
@@ -99,6 +135,15 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops, | |||
goto err_pool_init; | |||
} | |||
|
|||
// Set default property "name" to pool if exists | |||
for (int i = 0; i < UMF_DEFAULT_SIZE; i++) { | |||
if (CTL_DEFAULT_ENTRIES[i][0] != '\0') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should only call it for entries with matching name, not all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, should be fine
src/pool/pool_disjoint_ctl.h
Outdated
@@ -0,0 +1,61 @@ | |||
/* | |||
* Copyright (C) 2025 Intel Corporation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho this should not be a .h files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
338947a
to
29380ba
Compare
@@ -35,7 +35,7 @@ TEST_F(test, ctl_by_handle_os_provider) { | |||
|
|||
int ipc_enabled = 0xBAD; | |||
ret = umfCtlGet("umf.provider.by_handle.params.ipc_enabled", hProvider, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're adding a new paramter and without testing values other than 0 it's not properly tested. At least mark in tests a TODO for future.
umf_os_memory_provider_params_handle_t os_memory_provider_params = NULL; | ||
umf_memory_provider_ops_t *os_provider_ops = umfOsMemoryProviderOps(); | ||
if (os_provider_ops == NULL) { | ||
GTEST_SKIP() << "OS memory provider is not supported!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yy? not sure what you mean
a8a7fe8
to
56b5408
Compare
312ed18
to
db7eca2
Compare
f55ddb1
to
141d7bc
Compare
33ceeeb
to
77692e1
Compare
6a2ed97
to
0c02aaa
Compare
[CTL] Add support for defaults
Description
This PR introduces initial support for setting up default values.
Checklist